< previous page page_105 next page >

Page 105
    usri2_num_logons As Long
    usri2_logon_server As Long ' Unicode string
    usri2_country_code As Long
    usri2_code_page As Long
End Type
Make It Work
It was time to write some code. I wanted to find out if I was on the right track or if there were some hidden problems I had not yet seen. I started by looking at the Win32 SDK documentation to see which fields were absolutely essential.
Both usri2_Name and usri2_Password were obviousit doesn't make much sense to create a user without a name or password.
I also needed a constant for the usri2_priv field. I found the constants in the lmaccess.h header file:
#define USER_PRIV_GUEST    0
#define USER_PRIV_USER     1
#define USER_PRIV_ADMIN    2
You might wonder how I find a specific constant when it can be hidden in any of the dozens of C header files. The truth is, I cheat. I use a text editor called Codewright (which, by the way, I highly recommend). This editor supports a feature called File Grepa text search across multiple files. I think Visual Studio has a similar feature, at least when using the Visual C++ IDE. You can also write a text search tool like this yourself using Visual Basic. Use the VB directory functions to build a list of files, then open them one at a time in text mode. Read each line and use the instr function to see if the text you are searching for is present. It may not be the most efficient way to search through files, but it's easy to program. Of course, you can always use Windows Explorer's search capability as well. But I digress again.
The constants quickly became the following:
Private Const USER_PRIV_GUEST = 0
Private Const USER_PRIV_USER = 1
Private Const USER_PRIV_ADMIN = 2
I also needed the constant UF_NORMAL_ACCOUNT for the usri2_flags parameter:
#define UF_NORMAL_ACCOUNT         0x0200

 
< previous page page_105 next page >